package com.example.logindb.sevices;

import com.example.logindb.entity.Relation;
import com.example.logindb.repository.RelationRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RelationServiceImpl implements RelationService {

    @Autowired
    RelationRepository relationRepository;

    //增加一个用户
    @Override
    public Relation addRelation(Relation relation) {
        return relationRepository.save(relation);
    }

    //通过ID来查询
    @Override
    public Relation getRelation(Integer guardianId) {
        return relationRepository.findAllByGuardianid(guardianId);
    }

    @Override
    public Relation edit(Relation relation) {
        return relationRepository.save(relation);
    }

    @Override
    public Relation getRelationByBid(Integer blindId) {
        return relationRepository.findAllByBlindid(blindId);
    }

    @Override
    public int count() {
        return (int) relationRepository.count();
    }

    @Override
    public Relation findAllByBid(int id) {
        return relationRepository.findAllByBlindid(id);
    }

    @Override
    public Relation findAllByGid(int id) {
        return relationRepository.findAllByGuardianid(id);
    }


}
